#include "command.hpp"


int main()
{
    Init init;
    Log log;
    
    //int shmid = createshm();
    int shmid = CreateShm();
    char* shmadder = (char*)shmat(shmid, nullptr, 0);
    int fd = open(FIFO_FILE, O_RDONLY);
    if (fd < 0)
    {
        log(_ERROR_, "error from fd open--processa.cpp, error code:%d", errno);
        exit(1);
    }

    struct shmid_ds shmds;
    while (true)
    {
        char c;
        ssize_t n = read(fd, &c, 1);
        if (n == 0) break;
        if (n < 0)  break;

        std::cout << "client say# " << shmadder << std::endl;

        shmctl(shmid, IPC_STAT, &shmds);
        std::cout << "shm_size:" << shmds.shm_segsz << std::endl;
    }

    close(fd);
    shmdt(shmadder);
    shmctl(shmid, IPC_RMID, nullptr);

    return 0;
}





